package com.ggh.controller;
import	java.util.HashMap;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ggh.entity.UserRecord;
import com.ggh.service.UserRecordService;
import com.ggh.util.JsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.management.Query;
import java.util.List;

/**
 * 查询战绩
 * @author jj
 * @date 2019/10/14 15:31
 */
@Controller
public class UserRecordController {
    @Autowired
    private UserRecordService userRecordService;
    /**
    * @description :查询全部战绩
    * @param pageNo
    * @param pageSize
    * @param userid
    * @return: java.util.List<com.ggh.entity.UserRecord>
    * @date : 2019/10/14 15:44
    * @author : jj
    * @throws
    */
    @RequestMapping(value = "/findAll",method = RequestMethod.POST)
    @ResponseBody
    public HashMap<String, Object>  findAll(Integer pageNo,Integer pageSize,Integer userid){
        IPage<UserRecord> page = new Page<>(pageNo, pageSize);
        IPage<UserRecord> pageResult = userRecordService.page(page, new QueryWrapper<UserRecord>().eq("userid",userid));
        List<UserRecord> records = pageResult.getRecords();
        HashMap<String, Object> map = new HashMap<> ();
        map.put("userid",userid);
        map.put("type", "HallZhanJi");
        map.put("messages", JsonUtils.get().toJson(records));
        return map;
    }

}
